// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   AdvancedSettings.java

package org.quickserver.util.xmlreader;

import java.io.Serializable;
import java.nio.charset.Charset;
import java.nio.charset.UnsupportedCharsetException;

public class AdvancedSettings
    implements Serializable
{

    public AdvancedSettings()
    {
        charset = "ISO-8859-1";
        byteBufferSize = 0x10000;
        backlog = 0;
        useDirectByteBuffer = true;
        socketLinger = -1;
        clientIdentifierClass = "org.quickserver.net.server.impl.OptimisticClientIdentifier";
        qSObjectPoolMakerClass = null;
        maxThreadsForNioWrite = 10;
        performancePreferencesConnectionTime = 0;
        performancePreferencesLatency = 0;
        performancePreferencesBandwidth = 0;
        clientSocketTcpNoDelay = false;
    }

    public void setCharset(String charset)
    {
        if(charset == null || charset.trim().length() == 0)
            return;
        if(!Charset.isSupported(charset))
        {
            throw new UnsupportedCharsetException(charset);
        } else
        {
            this.charset = charset;
            return;
        }
    }

    public String getCharset()
    {
        return charset;
    }

    public void setByteBufferSize(int byteBufferSize)
    {
        if(byteBufferSize > 0)
            this.byteBufferSize = byteBufferSize;
    }

    public int getByteBufferSize()
    {
        return byteBufferSize;
    }

    public void setBacklog(int backlog)
    {
        if(backlog >= 0)
            this.backlog = backlog;
    }

    public int getBacklog()
    {
        return backlog;
    }

    public void setUseDirectByteBuffer(boolean flag)
    {
        useDirectByteBuffer = flag;
    }

    public boolean getUseDirectByteBuffer()
    {
        return useDirectByteBuffer;
    }

    public void setSocketLinger(int socketLinger)
    {
        this.socketLinger = socketLinger;
    }

    public int getSocketLinger()
    {
        return socketLinger;
    }

    public void setDebugNonBlockingMode(boolean debugNonBlockingMode)
    {
        this.debugNonBlockingMode = debugNonBlockingMode;
    }

    public boolean getDebugNonBlockingMode()
    {
        return debugNonBlockingMode;
    }

    public void setClientIdentifier(String clientIdentifierClass)
    {
        if(clientIdentifierClass == null || clientIdentifierClass.trim().length() == 0)
        {
            return;
        } else
        {
            this.clientIdentifierClass = clientIdentifierClass;
            return;
        }
    }

    public String getClientIdentifier()
    {
        return clientIdentifierClass;
    }

    public void setQSObjectPoolMaker(String qSObjectPoolMakerClass)
    {
        this.qSObjectPoolMakerClass = qSObjectPoolMakerClass;
    }

    public String getQSObjectPoolMaker()
    {
        if(qSObjectPoolMakerClass == null)
            qSObjectPoolMakerClass = "org.quickserver.util.pool.MakeQSObjectPool";
        return qSObjectPoolMakerClass;
    }

    public void setMaxThreadsForNioWrite(int maxThreadsForNioWrite)
    {
        this.maxThreadsForNioWrite = maxThreadsForNioWrite;
    }

    public int getMaxThreadsForNioWrite()
    {
        return maxThreadsForNioWrite;
    }

    public String toXML(String pad)
    {
        if(pad == null)
            pad = "";
        StringBuilder sb = new StringBuilder();
        sb.append(pad).append("<advanced-settings>\n");
        sb.append((new StringBuilder(String.valueOf(pad))).append("\t<charset>").toString()).append(getCharset()).append("</charset>\n");
        sb.append(pad).append("\t<use-direct-byte-buffer>").append(getUseDirectByteBuffer()).append("</use-direct-byte-buffer>\n");
        sb.append(pad).append("\t<byte-buffer-size>").append(getByteBufferSize()).append("</byte-buffer-size>\n");
        sb.append(pad).append("\t<backlog>").append(getBacklog()).append("</backlog>\n");
        sb.append(pad).append("\t<socket-linger>").append(getSocketLinger()).append("</socket-linger>\n");
        sb.append(pad).append("\t<debug-non-blocking-mode>").append(getDebugNonBlockingMode()).append("</debug-non-blocking-mode>\n");
        sb.append(pad).append("\t<client-identifier>").append(getClientIdentifier()).append("</client-identifier>\n");
        sb.append(pad).append("\t<qsobject-pool-maker>").append(getQSObjectPoolMaker()).append("</qsobject-pool-maker>\n");
        sb.append(pad).append("\t<max-threads-for-nio-write>").append(getMaxThreadsForNioWrite()).append("</max-threads-for-nio-write>\n");
        sb.append(pad).append("\t<performance-preferences-connection-time>").append(getPerformancePreferencesConnectionTime()).append("</performance-preferences-connection-time>\n");
        sb.append(pad).append("\t<performance-preferences-latency>").append(getPerformancePreferencesLatency()).append("</performance-preferences-latency>\n");
        sb.append(pad).append("\t<performance-preferences-bandwidth>").append(getPerformancePreferencesBandwidth()).append("</performance-preferences-bandwidth>\n");
        sb.append(pad).append("\t<client-socket-tcp-no-delay>").append(getClientSocketTcpNoDelay()).append("</client-socket-tcp-no-delay>\n");
        if(getClientSocketTrafficClass() != null)
            sb.append(pad).append("\t<client-socket-traffic-class>").append(getClientSocketTrafficClass()).append("</client-socket-traffic-class>\n");
        if(getClientSocketReceiveBufferSize() != 0)
            sb.append(pad).append("\t<client-socket-receive-buffer-size>").append(getClientSocketReceiveBufferSize()).append("</client-socket-receive-buffer-size>\n");
        if(getClientSocketSendBufferSize() != 0)
            sb.append(pad).append("\t<client-socket-send-buffer-size>").append(getClientSocketSendBufferSize()).append("</client-socket-send-buffer-size>\n");
        sb.append(pad).append("</advanced-settings>\n");
        return sb.toString();
    }

    public int getPerformancePreferencesConnectionTime()
    {
        return performancePreferencesConnectionTime;
    }

    public void setPerformancePreferencesConnectionTime(int performancePreferencesConnectionTime)
    {
        this.performancePreferencesConnectionTime = performancePreferencesConnectionTime;
    }

    public int getPerformancePreferencesLatency()
    {
        return performancePreferencesLatency;
    }

    public void setPerformancePreferencesLatency(int performancePreferencesLatency)
    {
        this.performancePreferencesLatency = performancePreferencesLatency;
    }

    public int getPerformancePreferencesBandwidth()
    {
        return performancePreferencesBandwidth;
    }

    public void setPerformancePreferencesBandwidth(int performancePreferencesBandwidth)
    {
        this.performancePreferencesBandwidth = performancePreferencesBandwidth;
    }

    public boolean getClientSocketTcpNoDelay()
    {
        return clientSocketTcpNoDelay;
    }

    public void setClientSocketTcpNoDelay(boolean clientSocketTcpNoDelay)
    {
        this.clientSocketTcpNoDelay = clientSocketTcpNoDelay;
    }

    public String getClientSocketTrafficClass()
    {
        return clientSocketTrafficClass;
    }

    public void setClientSocketTrafficClass(String clientSocketTrafficClass)
    {
        this.clientSocketTrafficClass = clientSocketTrafficClass;
    }

    public int getClientSocketReceiveBufferSize()
    {
        return clientSocketReceiveBufferSize;
    }

    public void setClientSocketReceiveBufferSize(int clientSocketReceiveBufferSize)
    {
        this.clientSocketReceiveBufferSize = clientSocketReceiveBufferSize;
    }

    public int getClientSocketSendBufferSize()
    {
        return clientSocketSendBufferSize;
    }

    public void setClientSocketSendBufferSize(int clientSocketSendBufferSize)
    {
        this.clientSocketSendBufferSize = clientSocketSendBufferSize;
    }

    private String charset;
    private int byteBufferSize;
    private int backlog;
    private boolean useDirectByteBuffer;
    private int socketLinger;
    private boolean debugNonBlockingMode;
    private String clientIdentifierClass;
    private String qSObjectPoolMakerClass;
    private int maxThreadsForNioWrite;
    private int performancePreferencesConnectionTime;
    private int performancePreferencesLatency;
    private int performancePreferencesBandwidth;
    private boolean clientSocketTcpNoDelay;
    private String clientSocketTrafficClass;
    private int clientSocketReceiveBufferSize;
    private int clientSocketSendBufferSize;
}
